<head xmlns:th="https://www.thymeleaf.org" th:fragment="head"
th:with="description=${isPost ? post != null ? post.status.excerpt : singlePage != null ? singlePage.status.excerpt : site.seo.description : site.seo.description}">
  <title th:text="${title + (#strings.isEmpty(site.subtitle) ? '' : '|' + site.subtitle)}"></title>
  <script th:if="${theme.config.enhance.enable_sw}" th:src="${(theme.config.enhance.enable_sw == 'uninstall')? #theme.assets('/assets/js/sw.min.js?uninstall=true') + '&mew=1.2.1' : '/sw.min.js?mew=1.2.1' + theme.config.enhance.enable_sw + '&cdn=' + theme.config.enhance.sw_cdn_source.replaceAll('\n', ',')}"></script>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
  <meta http-equiv="x-dns-prefetch-control" content="on">
  <meta name="keywords" th:content="${site.seo.keywords}"/>
  <meta name="description" th:content="${description}">
  <meta name="author" th:content="${site.title}">
  <meta name="site" th:content="${site.url}">
  <meta property="og:type" content="website">
  <meta property="og:title" th:content="${site.title}">
  <meta property="og:url" th:content="${canonical}">
  <meta property="og:site_name" th:content="${title}">
  <meta property="og:description" th:content="${description}">
  <meta property="og:locale" content="zh">
  <meta property="og:image" th:content="${site.logo}">
  <meta name="twitter:card" content="summary">
  <meta name="twitter:title" th:content="${title}">
  <meta name="twitter:description" th:content="${description}">
  <meta name="twitter:image" th:content="${site.logo}">
  <link rel="canonical" th:href="${canonical}"/>

  <link rel="preload stylesheet" as="style" th:href="@{/assets/css/theme.min.css(mew=${theme.spec.version})}">
  <link rel="preload stylesheet" as="style" th:href="@{/assets/lib/remixicon@3.5.0/remixicon.min.css}">
  <link rel="preload stylesheet" as="style" th:href="@{/assets/css/style.min.css(mew=${theme.spec.version})}">
  <link th:if="${theme.config.basic_style.theme_style == 'celebration'}" rel="preload stylesheet" as="style" th:href="@{/assets/css/celebration.min.css(mew=${theme.spec.version})}">

  <th:block th:if="${isPost}">
    <link data-pjax rel="preload stylesheet" as="style"
          th:href="@{'/assets/lib/highlightjs@11.5.1/styles/' + ${theme.config.post.code_pretty} + '.min.css'}"/>
    <link data-pjax rel="preload stylesheet" as="style" th:href="@{/assets/css/post.min.css(mew=${theme.spec.version})}"/>
    <link th:if="${enableKatex}" data-pjax rel="preload stylesheet" as="style" th:href="@{/assets/lib/katex@0.12.0/katex.min.css}"/>
    <link th:if="${enableShare}" data-pjax rel="preload stylesheet" as="style" th:href="@{/assets/css/dshare.min.css(mew=${theme.spec.version})}">
  </th:block>

  <link rel="stylesheet" th:href="@{/assets/css/mew-custom.min.css(mew=${theme.spec.version})}">
  <link th:if="${isPost == true || isPhotos == true}" data-pjax rel="stylesheet" th:href="@{/assets/lib/fancybox@5.3.7/jquery.fancybox.min.css}">
  <link rel="stylesheet" th:href="@{/assets/lib/qmsg/qmsg.min.css}">

  <link th:if="${theme.config.enhance.cursor_style != 'none'}" rel="stylesheet" th:href="@{/assets/css/cursor.min.css(mew=${theme.spec.version})}">

  <th:block th:replace="~{common/config}"/>

  <script th:src="@{/assets/lib/jquery@3.5.1/jquery.min.js}"></script>

  <link th:if="${!#strings.isEmpty(theme.config.custom.external_css)}" rel="stylesheet" th:href="${theme.config.custom.external_css}">
  <style th:if="${!#strings.isEmpty(theme.config.custom.inline_css)}" type="text/css" th:utext="${theme.config.custom.inline_css}"></style>
  [(${theme.config.custom.external_js_head})]
  <script th:if="${!#strings.isEmpty(theme.config.custom.inline_js_head)}" type="text/javascript" th:utext="${theme.config.custom.inline_js_head}">
  </script>
</head>